var n = getApp();

Page({
    data: {
        imageurl: "",
        ad: {}
    },
    onShow(){
        this.setData({
            ad: ''
        });
        this.setData({
            ad: getApp().globalData.selfAd[parseInt(getApp().globalData.selfAd.length*Math.random())]
        });
    },
    onLoad: function(a) {
        this.setData({
            imageurl: a.imageurl
        });
    },
    save: function() {
        wx.saveImageToPhotosAlbum({
            filePath: this.data.imageurl,
            success: function(n) {
                wx.showToast({
                    title: "保存成功"
                });
            },
            fail: function(n) {
                console.log("err:" + n), wx.showToast({
                    title: "保存失败",
                    icon: "none"
                });
            }
        });
    },
    previewImage: function(n) {
        var a = this, e = [];
        e.push(a.data.imageurl), wx.previewImage({
            current: e[0],
            urls: e
        });
    },
    onReady: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return {
            title: "超好用的图片编辑小程序",
            path: "pages/index/index"
        };
    }
});